import type { User } from '@/types/user'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore(
  'user',
  () => {
    const userInfo = ref<User>()

    const saveUser = (u: User) => {
      userInfo.value = u
    }

    const delUser = () => {
      userInfo.value = undefined
    }

    return { userInfo, saveUser, delUser }
  },
  { persist: true }
)
